//
//  IntroduceViewController.m
//  SmartLife
//
//  Created by Lawrence on 15/10/29.
//  Copyright © 2015年 Lawrence. All rights reserved.
//

#import "IntroduceViewController.h"
#import "ABCIntroduceViewController.h"
#import "MenuViewController.h"
#import "SmartLifeListViewController.h"
#import <RESideMenu.h>
#import "AppDelegate.h"

@interface IntroduceViewController ()<ABCIntroduceViewControllerDelegate,RESideMenuDelegate,UIApplicationDelegate>

@property ABCIntroduceViewController *IntroduceView;
@property SmartLifeListViewController *list;
@end

@implementation IntroduceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initIntroView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)initIntroView{
    
    self.IntroduceView=[[ABCIntroduceViewController alloc] initWithFrame:self.view.frame];
    self.IntroduceView.delegate=self;
    self.IntroduceView.backgroundColor=[UIColor groupTableViewBackgroundColor];
    [self.view addSubview:self.IntroduceView];
    
}

-(void)onDoneButtonPressed{
    [UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.IntroduceView.alpha = 0;
    } completion:^(BOOL finished) {
        [self.IntroduceView removeFromSuperview];
        
        [self initRootViewController];
        
    }];
}

-(void)initRootViewController{
    
    self.list=[[SmartLifeListViewController alloc] init];
    
    //添加导航栏
    UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:self.list];
    // window.rootViewController=navController;
    
    
    //导入侧滑框架
    MenuViewController *menuView=[[MenuViewController alloc] init];
    RESideMenu *sideMenu=[[RESideMenu alloc] initWithContentViewController:navController leftMenuViewController:menuView rightMenuViewController:nil];
    sideMenu.menuPreferredStatusBarStyle=1;
    sideMenu.delegate=self;
    sideMenu.contentViewShadowColor=[UIColor clearColor];
    sideMenu.backgroundImage=[UIImage imageNamed:@"background_blur"];
    sideMenu.contentViewShadowOffset=CGSizeMake(0, 0);
    sideMenu.contentViewShadowOpacity=0.6;
    sideMenu.contentViewShadowRadius=12;
    sideMenu.contentViewShadowEnabled=YES;
    
    
    UIApplication *application=[UIApplication sharedApplication];
    AppDelegate *appDelegate=application.delegate;
    
    appDelegate.window.rootViewController=sideMenu;
    
}
@end
